package model;

import java.beans.PropertyChangeSupport;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlTransient;

@XmlAccessorType(XmlAccessType.FIELD)
public class User implements Comparable<User> {

	public enum Property {
		NAME
	}

	private String name;

	@XmlTransient
	private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(
			this);

	@SuppressWarnings("unused")
	private User() {
	}

	public User(String name) {
		super();
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		String oldName = this.name;
		this.name = name;
		propertyChangeSupport.firePropertyChange(Property.NAME.name(), oldName,
				this.name);
	}

	@Override
	public int compareTo(User user) {
		return this.name.compareToIgnoreCase(user.name);
	}

	@Override
	public boolean equals(Object other) {
		if (other != null && other instanceof User) {
			User user = (User) other;
			return this.name.equalsIgnoreCase(user.name);
		} else {
			return false;
		}
	}

}
